package com.example.appforphysician;

import java.util.ArrayList;
import java.util.List;

import com.example.appforphysician.adapter.Management;
import com.example.appforphysician.adapter.ManagementAdapter;

import android.R.string;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.Menu;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.webkit.WebChromeClient.CustomViewCallback;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
 

public class ManagerActivity extends FragmentActivity {
    final String[] data ={"Profile","Schedule","Update Status Patient"};
    final String[] fragments ={
            "com.example.appforphysician.fragment.FragmentProfile",
            "com.example.appforphysician.fragment.FragmentSchedule",
            "com.example.appforphysician.fragment.FragmentUpdateStatusPatient"};
    DrawerLayout drawerLayout;
    ListView navList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_manager);
         
         
  //      ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActionBar().getThemedContext(), android.R.layout.simple_list_item_1, data);
         drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
         navList = (ListView) findViewById(R.id.drawer);
//         Button buttonOpenDrawerList = (Button)findViewById(R.id.bttOpendrawer);
//         buttonOpenDrawerList.setOnClickListener(buttonOpenDrawerListClickListener);
         //--------------------
         Management management_data[] = new Management[]
        	        {
        	            new Management(R.drawable.icon_patient, "Profile"),
        	            new Management(R.drawable.icon_record, "Schedule"),
        	            new Management(R.drawable.icon_patient, "Update Status Patient")
        	        };
        	        
        ManagementAdapter adapter = new ManagementAdapter(this, 
                R.layout.item_listview_management, management_data);           
         
         //------------------------end
         navList.setAdapter(adapter);
         navList.setOnItemClickListener(new OnItemClickListener(){
             @Override
             public void onItemClick(AdapterView<?> parent, View view, final int pos,long id){
            	 drawerLayout.setDrawerListener( new DrawerLayout.SimpleDrawerListener(){
                             @Override
                             public void onDrawerClosed(View drawerView){
                                     super.onDrawerClosed(drawerView);
                                     FragmentTransaction tx = getSupportFragmentManager().beginTransaction();
                                     tx.replace(R.id.subfragment_parent, Fragment.instantiate(ManagerActivity.this, fragments[pos]));
                                     tx.commit();
                             }
                     });
            	 drawerLayout.closeDrawer(navList);
             }
     });
     FragmentTransaction tx = getSupportFragmentManager().beginTransaction();
     tx.replace(R.id.subfragment_parent,Fragment.instantiate(ManagerActivity.this, fragments[0]));
     tx.commit();
         
         
    }
    //end---onCreate
    private View.OnClickListener buttonOpenDrawerListClickListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
        	drawerLayout.openDrawer(navList);
        }
    };


}